<template>
  <div class="">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="开始时间" prop="startTime">
        <el-date-picker v-model="queryParams.startTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endTime">
        <el-date-picker v-model="queryParams.endTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="选择结束时间" default-time="23:59:59">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <!-- <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleExport"
          :disabled="total<=0">导出</el-button> -->
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="流水号" align="left" prop="id" />
      <el-table-column label="类型" align="center" prop="amtTypeName" width="80" />
      <el-table-column label="变动金额" align="center" prop="amt" />
      <el-table-column label="账户余额" align="center" prop="afterAmt" />
      <!-- <el-table-column label="操作站点" align="center" prop="optStaitonName"/> -->
      <el-table-column label="时间" align="center" prop="createTime" width="155" />
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleView(scope.row)">详情</el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
  import {
    acc
  } from "@/api/fleet";

  export default {
    name: "Acc",
    data() {
      return {
        buttonLoading: false,
        loading: true,
        showSearch: true,
        total: 0,
        dataList: [],
        title: "",
        open: false,
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          memberId: undefined,
          startTime: undefined,
          endTime: undefined
        },
        form: {

        },
        rules: {

        }
      };
    },
    created() {
      let range = this.timeForRange(-7)
      // console.log('日期范围', range)
      this.queryParams.startTime = range[0]
      this.queryParams.endTime = range[1]
      this.getList();
    },
    methods: {
      getList() {
        this.loading = true;
        acc(this.queryParams).then(response => {
          this.dataList = response.data.rows;
          this.total = parseInt(response.data.total);
          this.loading = false;
        }).catch(() => this.loading = false);
      },
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      handleExport() {
        this.download('/crm/fleet/fuelOrderExport', {
          ...this.queryParams
        }, `资金流水_${new Date().getTime()}.xlsx`)
      },
      handleView(row) {
        this.reset();
        this.form = row;
        this.open = true;
        this.title = `资金流水详情 - ${row.id}`;
      }
    }
  };
</script>
